package solved;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	holstein
*/
public class holstein {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("holstein.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"holstein.out")));
		new holstein().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private int 	V;
	private int[] 	v;
	private int		G;
	private int[][] g;
	private int[]	res;
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		V = read(f);
		v = read(f, V);
		G = read(f);
		g = new int[G][V];
		for (int i=0; i<G; i++) {
			g[i] = read(f, V);
		}
		
		for (int i=1; i<=G; i++) {
			res = new int[i];
			if (search(0, 0, i)) break;
		}
		
		out.print(res.length + " ");
		for (int i=0; i<res.length; i++) {
			out.print(i==0? res[i]+1 : " " + (res[i]+1));
		}
		out.println();
	}
	
	private boolean search(int i, int low, int N) {
		if (i==N) return satisfy();
		for (int j=low; j<G; j++) {
			res[i] = j;
			if (search(i+1, j+1, N)) return true;
		}
		return false;
	}
	
	private boolean satisfy() {
		for (int i=0; i<V; i++) {
			int total = v[i];
			for (int j=0; j<res.length; j++) {
				total -= g[res[j]][i];
			}
			if (total > 0) return false;
		}
		return true;
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
	
	public int[] read(BufferedReader f, int N) throws IOException {
		String[] t = f.readLine().split("\\s+");
		int[] a = new int[N];
		for (int i=0; i<N; i++) {
			a[i] = Integer.parseInt(t[i]);
		}
		return a;
	}
}

